#ifndef BSP_DRIVER_GICV3_GICV3_CPUIF_H
#define BSP_DRIVER_GICV3_GICV3_CPUIF_H

// ------------------------------------------------------------
// CPU Interface functions
// ------------------------------------------------------------

// Enables group 0 interrupts
// The lowest EL that access the ICC_IGRPEN0_EL1 is determined
// by the routine of the FIQ exception.
void enableGroup0Ints(void);

// Disables group 0 interrupts
// The lowest EL that access the ICC_IGRPEN0_EL1 is determined
// by the routine of the FIQ exception.
void disableGroup0Ints(void);

// Enables group 1 interrupts for current security state
// The lowest EL that access the ICC_IGRPEN1_EL1 is determined
// by the routine of the IRQ exception.
void enableGroup1Ints(void);

// Disables group 1 interrupts for current security state
// The lowest EL that access the ICC_IGRPEN1_EL1 is determined
// by the routine of the IRQ exception.
void disableGroup1Ints(void);

// Enables group 1 interrupts for non-secure state
//
// Used by EL3 to enable non-secure group 1 interrupts
void enableNSGroup1Ints(void);

// Disables group 1 interrupts for non-secure state
//
// Used by EL3 to disable non-secure group 1 interrupts
void disableNSGroup1Ints(void);

// Returns the value of the ICC_IAR0_EL1 (Group 0 Interrupt Acknowledge)
u32 readIARGrp0(void);

// Writes INTID to the End Of Interrupt register
void writeEOIGrp0(u32 INTID);

// Writes INTID to the De-active Interrupt register
void writeDIR(u32 INTID);

// Returns the value of the ICC_IAR1_EL1 (Group 1 Interrupt Acknowledge)
u32 readIARGrp1(void);

// Writes INTID to the Aliased End Of Interrupt register
void writeEOIGrp1(u32 INTID);

// Sets the Priority mask register for the core run on
// priority - mask value (8-bit unsigned value).
//
// NOTE: An interrupt must be high priority (lower numeric value) than the mask to be sent
void setPriorityMask(u32 priority);

u32 getPriorityMask(void);

// Sets ICC_BPR0_EL1 for the core run on
// priority - Binary piont value
void setBPR0(u32 priority);

// Sets ICC_BPR1_EL1 for the core run on
// priority - Binary piont value
void setBPR1(u32 priority);

u32 getBPR1(void);

// Returns the priority of the current active interrupt
u32 getRunningPriority(void);

void setICC_SRE_EL1(u32 value);

u32 getICC_SRE_EL1(void);

u32 getHPPIR1(void);

void setHPPIR1(u32 ID);

u32 getICC_CTLR_EL1(void);

void setICC_CTLR_EL1(u32 value);

void sendGroup1SGI(u64 ID, u64 mode, u64 target_list);

#endif
